home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / Other Langs / Tickle-4.0 (tcl) / library / help / tcl / filescan / scanmatch < prev   
Encoding:
Text File  |  1993-10-26  |  3.4 KB  |  70 lines  |  [TEXT/$Tcl]

  1.  
  2.  
  3.           scanmatch ?-nocase? contexthandle ?regexp? commands
  4.                Specify Tcl commands, to be evaluated  when  regexp  is
  5.                matched  by  a scanfile command.  The match is added to
  6.                the  scan  context  specified  by  contexthandle.   Any
  7.                number  of match statements may be specified for a give
  8.                context.  Regexp  is  a  regular  expression  (see  the
  9.                regexp  command).  If -nocase is specified as the first
  10.                argument, the pattern is matched regardless  of  alpha-
  11.                betic case.
  12.  
  13.                If regexp is not specified, then  a  default  match  is
  14.                specified for the scan context.  The default match will
  15.                be executed when a line of the file does not match  any
  16.                of the regular expressions in the current scancontext.
  17.  
  18.                The array matchInfo is available to the Tcl  code  that
  19.                is  executed  when an expression matches (or defaults).
  20.                It contans information about the file being scanned and
  21.                where within it the expression was matched.
  22.  
  23.                matchInfo is local to the top level of the  match  com-
  24.                mand  unless  declared  global at that level by the Tcl
  25.                global command.  If it is to be used as  a  global,  it
  26.                must  be  declared  global  before  scanfile  is called
  27.                (since scanfile sets the  matchInfo  before  the  match
  28.                code is executed, a subsequent global will override the
  29.                local  variable).   The  following  array  entries  are
  30.                available:
  31.  
  32.                matchInfo(line)
  33.                     Contains the text of the line of the file that was
  34.                     matched.
  35.  
  36.                matchInfo(offset)
  37.                     The byte offset into the file of the first charac-
  38.                     ter of the line that was matched.
  39.  
  40.                matchInfo(linenum)
  41.                     The line number of the line that was matched. This
  42.                     is  relative  to  the first line scanned, which is
  43.                     usually, but not necessarily, the  first  line  of
  44.                     the file.  The first line is line number one.
  45.  
  46.                matchInfo(handle)
  47.                     The file id (handle) of the file  currently  being
  48.                     scanned.
  49.  
  50.                matchInfo(submatch0)
  51.                     Will contain the  characters  matching  the  first
  52.                     parenthesized  subexpression.   The second will be
  53.                     contained in submatch1, etc.
  54.  
  55.                matchInfo(subindex0)
  56.                     Will contain the a list of the starting and ending
  57.                     indices   of   the   string   matching  the  first
  58.                     parenthesized subexpression.  The second  will  be
  59.                     contained in subindex1, etc.
  60.  
  61.           All scanmatch patterns that match a line will  be  processed
  62.           in the order in which their specifications were added to the
  63.           scan context.   The  remainder  of  the  scanmatch  pattern-
  64.           command  pairs  may be skipped for a file line if a continue
  65.           is executed by the Tcl code of a preceding, matched pattern.
  66.  
  67.           If a return is executed in the body of  the  match  command,
  68.           the scanfile command currently in progress returns, with the
  69.           value passed to return as its return value.
  70.